var administrator = 
{
	ToogleCheckbox: function(chk) {
		var checkedVal = parseInt($(chk).attr('status'));
		if(checkedVal == 0)
		{
			$(chk).attr('status', 1);
			$(chk).attr('src','/AnGiang-557-portlet/html/giamsatmoitruong/images/administrator/checked.png');
		}
		else
		{
			$(chk).attr('status', 0);
			$(chk).attr('src','/AnGiang-557-portlet/html/giamsatmoitruong/images/administrator/unchecked.png');
		}
	},
	
	// chon 1 tuyen duong trong bang danh sach tuyen duong
	ToogleCheckbox_Tuyenduong: function(chk) {
		var imgNames = document.getElementsByName("imgMapInserFromTemplateTuyenduong");
		$(imgNames).attr('src','/AnGiang-557-portlet/html/giamsatmoitruong/images/administrator/unchecked.png');
		$(imgNames).attr('status', 0);
		$(chk).attr('status', 1);
		$(chk).attr('src','/AnGiang-557-portlet/html/giamsatmoitruong/images/administrator/checked.png');
		// select tuyen dg
		var maTD = $(chk).attr('maTD');
		// tim geom ung voi maTD
		Zoom.geomTimduong = null;
		for(var j=0; j<MapAction.geomTimduong.length; j++)
		{
			var objTD = MapAction.geomTimduong[j];
			if(maTD == objTD[0])
			{
				Zoom.geomTimduong = objTD[2];
				vectorGraphics.removeAllFeatures();
				createLineFromGeometry(vectorGraphics, Zoom.geomTimduong, null);
				break;
			}
		}
	},
	

	gouprPermission_submit: function ()
	{
		var rowsCollectopn = $('#tbl_administrator_group_permission')[0].rows;
		var i = 1;
		var valHidden = '';
		for(i=1; i<rowsCollectopn.length - 1; i++)
		{
			var moduleID = $(rowsCollectopn[i].cells[1]).text();
			var checkView = parseInt($(rowsCollectopn[i].cells[3]).find('img').attr('status'));
			checkView = checkView==NaN ? 0 : checkView;
			var checkEdit = parseInt($(rowsCollectopn[i].cells[4]).find('img').attr('status'));
			checkEdit = checkEdit==NaN ? 0 : checkEdit;
			//if(checkView == 0 && checkEdit == 0) continue;
			valHidden += moduleID + '-' + checkView + '-' + checkEdit + '&';
		}
		$('#txt_hidden_administrator_group_permission_chk').val(valHidden);
		//alert($('#txt_hidden_administrator_group_permission_chk').val());
		return true;
	},
	
	gouprMembers_submit: function() {
		var rowsCollectopn = $('#tbl_administrator_group_members')[0].rows;
		var i = 1;
		var valHidden = '';
		for(i=1; i<rowsCollectopn.length - 1; i++)
		{
			var userID = $(rowsCollectopn[i].cells[1]).text();
			var checkMember = parseInt($(rowsCollectopn[i].cells[3]).find('img').attr('status'));
			checkMember = checkMember==NaN ? 0 : checkMember;
			if(checkMember == 1) valHidden += userID + '&';
		}
		$('#txt_hidden_administrator_group_members_chk').val(valHidden);
		//alert($('#txt_hidden_administrator_group_members_chk').val());
		return true;
	},
	
	userAddGroup_submit: function() {
		var rowsCollectopn = $('#tbl_administrator_user_addgroup')[0].rows;
		var i = 1;
		var valHidden = '';
		for(i=1; i<rowsCollectopn.length - 1; i++)
		{
			var groupID = $(rowsCollectopn[i].cells[1]).text();
			var checkMember = parseInt($(rowsCollectopn[i].cells[3]).find('img').attr('status'));
			checkMember = checkMember==NaN ? 0 : checkMember;
			if(checkMember == 1) valHidden += groupID + '&';
		}
		$('#txt_hidden_administrator_user_addgroup_chk').val(valHidden);
		//alert($('#txt_hidden_administrator_user_addgroup_chk').val());
		return true;
	},
	
	userPermission_submit: function() {
		var rowsCollectopn = $('#tbl_administrator_user_permission')[0].rows;
		var i = 1;
		var valHidden = '';
		for(i=1; i<rowsCollectopn.length - 1; i++)
		{
			var moduleID = $(rowsCollectopn[i].cells[1]).text();
			var checkView = parseInt($(rowsCollectopn[i].cells[3]).find('img').attr('status'));
			checkView = checkView==NaN ? 0 : checkView;
			var checkEdit = parseInt($(rowsCollectopn[i].cells[4]).find('img').attr('status'));
			checkEdit = checkEdit==NaN ? 0 : checkEdit;
			if(checkView == 1 || checkEdit == 1) valHidden += moduleID + '-' + checkView + '-' + checkEdit + '&';
		}
		$('#txt_hidden_administrator_user_permission_chk').val(valHidden);
		//alert($('#txt_hidden_administrator_user_permission_chk').val());
		return true;
	}
};

